<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>此页面<span id="s">5</span>后返回到上一页</h1>
<script>
    var sec = 5;
    var sObj = document.getElementById('s')
    function foo(){
        sObj.innerHTML = sec;
        if (sec == 0){
            location.href = 'http://www.baidu.com';
        }
        sec--;
    }
    setInterval(foo,1000);
</script>
</body>
</html>